package com.ktgj.service.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.service.domain.OrderstatusTracking;
import com.ktgj.service.service.IOrderstatusTrackingService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 订单状态跟踪Controller
 * 
 * @author ruoyi
 * @date 2021-09-03
 */
@ControllerAdvice
@RestController
@RequestMapping("/ordertracking")
public class OrderstatusTrackingController extends BaseController
{
    @Autowired
    private IOrderstatusTrackingService orderstatusTrackingService;

    /**
     * 查询订单状态跟踪列表
     */
    @PreAuthorize(hasPermi = "service:tracking:list")
    @GetMapping("/list")
    public TableDataInfo list(OrderstatusTracking orderstatusTracking)
    {
        startPage();
        List<OrderstatusTracking> list = orderstatusTrackingService.selectOrderstatusTrackingList(orderstatusTracking);
        return getDataTable(list);
    }

    /**
     * 导出订单状态跟踪列表
     */
    @PreAuthorize(hasPermi = "service:tracking:export")
    @Log(title = "订单状态跟踪 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderstatusTracking orderstatusTracking) throws IOException
    {
        List<OrderstatusTracking> list = orderstatusTrackingService.selectOrderstatusTrackingList(orderstatusTracking);
        ExcelUtil<OrderstatusTracking> util = new ExcelUtil<OrderstatusTracking>(OrderstatusTracking.class);
        util.exportExcel(response, list, "订单状态跟踪 数据");
    }

    /**
     * 获取订单状态跟踪详细信息
     */
    @PreAuthorize(hasPermi = "service:tracking:query")
    @GetMapping(value = "/{orderTrackingId}")
    public AjaxResult getInfo(@PathVariable("orderTrackingId") Long orderTrackingId)
    {
        return AjaxResult.success(orderstatusTrackingService.selectOrderstatusTrackingById(orderTrackingId));
    }

    /**
     * 新增订单状态跟踪
     */
    @PreAuthorize(hasPermi = "service:tracking:add")
    @Log(title = "订单状态跟踪 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderstatusTracking orderstatusTracking)
    {
        return toAjax(orderstatusTrackingService.insertOrderstatusTracking(orderstatusTracking));
    }

    /**
     * 修改订单状态跟踪
     */
    @PreAuthorize(hasPermi = "service:tracking:edit")
    @Log(title = "订单状态跟踪 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderstatusTracking orderstatusTracking)
    {
        return toAjax(orderstatusTrackingService.updateOrderstatusTracking(orderstatusTracking));
    }

    /**
     * 删除订单状态跟踪
     */
    @PreAuthorize(hasPermi = "service:tracking:remove")
    @Log(title = "订单状态跟踪 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderTrackingIds}")
    public AjaxResult remove(@PathVariable Long[] orderTrackingIds)
    {
        return toAjax(orderstatusTrackingService.deleteOrderstatusTrackingByIds(orderTrackingIds));
    }
}
